'use strict'

module.exports = () => {
  return async function (ctx, next) {
    let { page, limit } = ctx.query

    page = parseInt(page) || 1
    limit = parseInt(limit) || 10

    ctx.state.page = page
    ctx.state.limit = limit
    ctx.state.skip = (page - 1) * limit
    return next()
  }
}
